import request from '@/config/axios'


/**
 * OperateLogRespVO，管理后台 - 操作日志 Response VO
 */
export interface OperateLogRespVO {
  /**
   * 操作明细
   */
  action?: string;
  /**
   * 操作模块业务编号
   */
  bizId: number;
  /**
   * 创建时间
   */
  createTime: Date;
  /**
   * 拓展字段
   */
  extra?: string;
  /**
   * 日志编号
   */
  id: number;
  /**
   * 请求方法名
   */
  requestMethod: string;
  /**
   * 请求地址
   */
  requestUrl: string;
  /**
   * 操作名
   */
  subType: string;
  /**
   * 链路追踪编号
   */
  traceId: string;
  transMap?: { [key: string]: { [key: string]: any } };
  /**
   * 操作模块类型
   */
  type: string;
  /**
   * 浏览器 UserAgent
   */
  userAgent: string;
  /**
   * 用户编号
   */
  userId: number;
  /**
   * 用户 IP
   */
  userIp: string;
  /**
   * 用户昵称
   */
  userName: string;
  [property: string]: any;
}


// 查询交易订单列表
export const getLogPage = async (params: any) => {
  return await request.get({ url: `/admin-api/system/operate-log/page`, params })
}

// 查询交易订单统计
export const getOrderSummary = async (params: any) => {
  return await request.get<TradeOrderSummaryRespVO>({ url: `/trade/order/summary`, params })
}

// 查询交易订单详情
export const getOrder = async (id: number | null) => {
  return await request.get({ url: `/trade/order/get-detail?id=` + id })
}

// 查询交易订单物流详情
export const getExpressTrackList = async (id: number | null) => {
  return await request.get({ url: `/trade/order/get-express-track-list?id=` + id })
}

export interface DeliveryVO {
  id?: number // 订单编号
  logisticsId: number | null // 物流公司编号
  logisticsNo: string // 物流编号
}

// 订单发货
export const deliveryOrder = async (data: DeliveryVO) => {
  return await request.put({ url: `/trade/order/delivery`, data })
}

// 订单备注
export const updateOrderRemark = async (data: any) => {
  return await request.put({ url: `/trade/order/update-remark`, data })
}

// 订单调价
export const updateOrderPrice = async (data: any) => {
  return await request.put({ url: `/trade/order/update-price`, data })
}

// 修改订单地址
export const updateOrderAddress = async (data: any) => {
  return await request.put({ url: `/trade/order/update-address`, data })
}

// 订单核销
export const pickUpOrder = async (id: number) => {
  return await request.put({ url: `/trade/order/pick-up-by-id?id=${id}` })
}

// 订单核销
export const pickUpOrderByVerifyCode = async (pickUpVerifyCode: string) => {
  return await request.put({
    url: `/trade/order/pick-up-by-verify-code`,
    params: { pickUpVerifyCode }
  })
}

// 查询核销码对应的订单
export const getOrderByPickUpVerifyCode = async (pickUpVerifyCode: string) => {
  return await request.get<OrderVO>({
    url: `/trade/order/get-by-pick-up-verify-code`,
    params: { pickUpVerifyCode }
  })
}
